﻿import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3

Button {
    id: homebtn
    property int nTab: 0
    property int nCurTab: 0
    property alias strText: title.text
    property alias icon: icon.source
    background: Rectangle {
                    color: nCurTab == nTab ? "#5b5b5b" : "transparent"
                    border.width: nCurTab == nTab ? 2 : 0;
                    border.color: "#00bb9e"

                    // 使用矩形覆盖上层Rectangle的边框
                    Rectangle {
                        color: parent.color
                        border.width: 0
                        anchors.fill: parent
                        // 使用Margin来确定是否显示边框
                        anchors.leftMargin: 0
                        anchors.topMargin: 0
                        anchors.rightMargin: 0
                        anchors.bottomMargin: 2
                    }
                }

    contentItem: Item {
        Image {
            id: icon
            width: 30
            height: 30
            fillMode: Image.PreserveAspectFit
            mipmap: true
            anchors.top: parent.top
            anchors.right: parent.right
            anchors.left: parent.left
            anchors.topMargin: 5
        }
        Text {
            id: title
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
            anchors.bottomMargin: 5
            color: "#dcdcdc"
            font.pixelSize: 12
        }
    }
}
